package com.sjb.sixteen_journey_backend.controller;


import com.sjb.sixteen_journey_backend.common.R;
import com.sjb.sixteen_journey_backend.entity.Comment;
import com.sjb.sixteen_journey_backend.entity.dto.CommentDto;
import com.sjb.sixteen_journey_backend.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论列表
 *
 * @author jcz
 * @since 2024-07-23
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private ICommentService commentService;

    /**
     * 添加评论
     * @param commentDto
     * @return
     */
    @PostMapping("/addComment")
    public R addComment(@RequestBody CommentDto commentDto){
        return commentService.addComment(commentDto);
    }

    /**
     * 显示评论列表
     * @param status
     * @param id
     * @return
     */
    @GetMapping("/showComment/{status}/{id}")
    public R showComment(@PathVariable("status") Integer status, @PathVariable("id") Integer id){
        return commentService.showComment(status,id);
    }

    /**
     * 删除评论
     * @param commentId
     * @return
     */
    @DeleteMapping("/deleteComment/{id}")
    public R deleteComment(@PathVariable("id") Integer commentId){
        return commentService.deleteComment(commentId);
    }

}
